#include <REGX52.H>
#include "LCD1602.h"
#include "delay.h"
#include "IR.h"

unsigned char num;
unsigned char address;
unsigned char command;

void main()
{
	LCD_Init();
	LCD_ShowString(1, 1, "ADDR  CMD  NUM");
	LCD_ShowString(2, 1, "00    00   000");
	
	IR_init();
	
	while(1)
	{
		// 若是数据接收完毕或者接收的是Repeat信号
		if(IR_getDataFlag() || IR_getRepeatFlag())
		{
			address = IR_getAddress();
			command = IR_getCommand();
			LCD_ShowHexNum(2, 1, address, 2);
			LCD_ShowHexNum(2, 7, command, 2);
			if(command == IR_PREVIOUS)
			{
				num--;
			}
			if(command == IR_NEXT)
			{
				num++;
			}
			LCD_ShowNum(2, 12, num, 3);
		}
	}
}
